package igou.togogo.service.impl;

import igou.togogo.bean.EBrand;
import igou.togogo.common.service.impl.BaseServiceImpl;
import igou.togogo.pojo.EgouResult;
import igou.togogo.service.IBrandService;
import igou.togogo.utils.HttpClientUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BrandServiceImpl extends BaseServiceImpl implements IBrandService {

    @Override
    public List<EBrand> getBrandList() {
        //rest 与 portal 分离 Http传输
        try {
            String json = HttpClientUtil.doGet(REST_BASE_URL + BRAND_LIST_URL);
            if (StringUtils.isNotBlank(json)){
                EgouResult result = EgouResult.formatToList(json, EBrand.class);
                return (List<EBrand>) result.getData();
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
